Подключаем почтовый сервис для рассылок электронных писем mailgun.com для 1С-Битрикс
, МихаилСкачиваем библиотеку https://github.com/mailgun/mailgun-php
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/bitrix/divasoft/mailgun-php/vendor/autoload.php';
use Mailgun\Mailgun;
function custom_mail($to, $subject, $message, $additionalHeaders = ''){
$mg = new Mailgun("key-*****");
$domain = "divasoft.ru";
/*$mg = new Mailgun('key-*****', null, 'bin.mailgun.net');
// TEST
$mg->setApiVersion('*******');
*/
//Получаем тему письма
$elements = imap_mime_header_decode($subject);
$title = '';
for ($i=0;
$i<count($elements);
$i++) {
$title .= $elements[$i]->text;
}
preg_match('/From: (.+)\n/i', $additionalHeaders, $matches);
list(, $from) = $matches;
preg_match('/BCC: (.+)\n/i', $additionalHeaders, $matches);
list(, $bcc) = $matches;
preg_match('/CC: (.+)\n/i', $additionalHeaders, $matches);
list(, $cc) = $matches;
preg_match('/Reply-To: (.+)\n/i', $additionalHeaders, $matches);
list(, $rt) = $matches;
$mg->sendMessage($domain, array('from' => $from,
'to' => $to,
'bcc' => $bcc,
'subject' => $subject,
'html' => $message,
'text' => strip_tags($message)));
// DEBUG
/*$result = $mg->get("$domain/log", array('limit' => 25,
'skip' => 0));
$logItems = $result->http_response_body->items;
foreach($logItems as $logItem){
//echo $logItem->message_id . "\n";
}*/
return true;
}
?>
И волшебный ответ для того, что бы аккаунт прошёл валидацию
"your account is temporarily disabled. business verification please contact support to resolve"
Hello! What types of emails will you be sending - transactional or marketing? transactional + marketing Register info, Order info, Promo mail. Where do you source your database of email addresses? CMS 1C-Bitrix (divasoft.ru) Are all of your email addresses double-opt in? I do not quite understand, but the mail has. What is your expected monthly volume of messages? 100-1000, we just start online-store Have you read our Email Best Practices document? Yes! Can you please give us the URL that your users use to sign up for your email as well as a link to your Terms of Service? In development, link to register page = https://divasoft.ru/login/?register=yes&backurl=%2F
p.s. этот сервис скрывает ip адрес сервера отправителя